<%@page import="org.cwq.frame.appframe.util.JsonUtil"%>
<%@page import="com.easou.web.controller.webrower.WebRoomController" language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.easou.doudizhu.user.UserSessionManager"%>
<%@page import="com.easou.doudizhu.utils.RandomUtil"%>
<%@page import="com.easou.cas.auth.EucAuthResult"%>
<%@page import="com.easou.doudizhu.global.Constant"%>
<%@page import="com.easou.web.utils.SpringContextUtil"%>
<%@page import="com.easou.web.vo.GameUserBO"%>
<%@page import="com.easou.doudizhu.operate.Room"%>
<%@page import="com.easou.doudizhu.room.IRoom"%>
<%@page import="com.easou.web.service.GameUserService"%>
<%@page import="com.easou.doudizhu.operate.RoomManager"%>
<%@page import="com.easou.web.utils.StatisticLogUtil"%>

<%
	String playerId = null;
	long userId = 0;
	String userIdStr = null;
	String nickName = null;
	String roleName = null;
	int beanFunCount = 0;
	int starCount = 0;
	int candyCount = 0;
	Object ouid = request.getSession().getAttribute(Constant.SESSION_UID);
	if(ouid != null){
		long uid = Long.valueOf(ouid.toString());
		GameUserBO bo = UserSessionManager.get(uid);
		
		if (bo != null) {
	IRoom room = RoomManager.getRoom(1);
	playerId = bo.getUserName();
	nickName = bo.getNickName();
	userId = bo.getUserId();
	userIdStr = String.valueOf(userId);
	beanFunCount = bo.getBeanfun();
	starCount = bo.getStar();
	candyCount = bo.getCandy();
	roleName = bo.getRoleResourceName();
	
		} else {
		  System.out.println("play.jsp -> 用户未登录 ，重定向到登录界面");
		}
	}
	StatisticLogUtil.userVisit(request.getSession().getId(),request.getHeader("USER-AGENT"),request.getParameter("qn"),userId);   //日志统计
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%
	if (request.getHeader("USER-AGENT").contains("iPhone") || request.getHeader("USER-AGENT").contains("iPod") || request.getHeader("USER-AGENT").contains("iPad")) {
%>
<meta name='viewport' content='target-densitydpi=480,user-scalable=no,maximum-scale=1.0'/>
<%
	} else {
%>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,target-densitydpi=high-dpi,user-scalable=no">
<%
	}
%>
<meta content="telephone=no" name="format-detection">
<META HTTP-EQUIV="pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="expires" CONTENT="0"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-store, must-revalidate"> 
<title>西游斗地主</title>
<link type="text/css" rel="stylesheet" href="css/common_new.css">
<link type="text/css" rel="stylesheet" href="css/main_new.css">


</head>


<body>

	<!--横屏-->
<div class="portrait"><img  src="images/portrait_480.png"   /></div>



<!--竖屏  舞台-->
<div id="scene" class="scene">
	<!--房间列表-->
	<div id="room" class="room" >
		
		<div class="main_head">
			<img id="room_info" class="main_head_peo" src="images/xy/<%=roleName%>/info.png"   />
			<span class="main_head_name">昵称：<%=nickName%></span>
			<span  class="main_head_num">金币：<span id="user-dou"><%=beanFunCount%></span></span>
		</div> 
		
		<!-- 按钮 -->
		
		
		<div id="matchGame" style="display:none"></div>
		 
		<!-- 关卡 --> 
		<div id="points" >
		</div>
		<span id="bigRoom" class="bigRoom">
			<img src="" />
			<span id="roomInfo" class="">1111</span>
		</span>

		
		<span id="startGame" class="btn_bg btn_startGame_pos"><span class="btn_startGame"></span></span>
		<span id="room_mall" class="btn_room_bg room_mall_pos"><span class="txt_room_mall"></span></span>
		<span id="room_pw" class="btn_room_bg room_pw_pos"><span class="txt_pw_mall"></span></span>	
		<!-- 星星 
		<span class="star_1 star starAnmi icon"></span>
		<span class="star_2 star starAnmi icon"></span>
		-->
		
	</div>
	

	<!--游戏界面-->
	<div id="playBox" class="playBox" style="display:none"></div>
	
</div>



<script src="js/zepto.min.js"></script>
<script src="js/esWebsocket.js"></script>
<script src="js/require.min.js"></script>
<script src="js/quark.base-1.0.0.min.js"></script>
<script src="js/common_new.js"></script>
<script src="js/sessionStorageKey.js"></script>
<script src="js/session.js"></script>
<script src="js/logic.js"></script>
<script src="js/rule.js"></script>
<script src="js/json2.js"></script>
<script src="js/ws.js"></script>
<script src="js/ws-logic.js"></script>
<script src="js/play.js"></script>
<script>
window.onload=function(){
	dataStorage.set(MyOwner.playerId, '<%=playerId%>');
	dataStorage.set(MyOwner.userId, '<%=userIdStr%>');
	dataStorage.set(MyOwner.roleName,'<%=roleName%>');
	<%List<Map<String, Object>> roomList=WebRoomController.getShowRoomList();%>
		var rooms = <%= JsonUtil.formateValue(roomList) %> ;
		room.createRoom(rooms);
		
	
		
	require(["js/mButton.js","js/mPage","js/mCommon.js","js/mCard.js"], function(button,page,common,card){  
			common.setSize(true);
			button.allButton();
			page.room();
			setTimeout(function(){
				card.setRoom('<%=beanFunCount%>');
				card.isOpenRoom('<%=beanFunCount%>');
			
			},100);
			
			var roomIndex = card.getMinRoom('<%=beanFunCount%>')
			setRoomInfo(roomIndex)
			
			$("#points>.btn_room").live("click",function(){
				var i = $("#points>.btn_room").index($(this))
				setRoomInfo(i)
			});
			
			function setRoomInfo(index){
				var roomList = $("#points>.btn_room")
				roomList.removeClass("room_select")
				roomList.eq(index).addClass("room_select");
				var roomId = roomList.eq(index).attr("room")
				$("#bigRoom>img").attr("src","images/xy/bigRoom_"+(index+1)+".png")
				$("#startGame").attr("room",roomId)
				var beanfunlimitdesc = roomList.eq(index).attr("beanfunlimitdesc")
				var online = roomList.eq(index).attr("online")
				$("#roomInfo").html("房间条件："+beanfunlimitdesc+"金币<br/>在线人数："+online+"人")
				$("#roomInfo").removeClass().addClass("roomInfo_"+(index+1))
			}
	}); 
	


 	
};

 function getServiceURL(){
		var pathName = window.location.pathname;
		var projectName = pathName.substring(0,pathName.substr(1).indexOf('/')+1);
		return "http://"+window.location.host + projectName;
	}
	
	function getWsUrl(){
		var pathName = window.location.pathname;
		var projectName = pathName.substring(0,pathName.substr(1).indexOf('/')+1);
		return "ws://"+window.location.host + projectName;
	}
	


</script>
</body>
</html>